package com.datong.server.strategy.calculatePrice;

//返现
public class ReturnCashStrategy extends StrategyCash {
    private double condition;
    private double returnCash;

    //实例化时需传入满多少返多少，如满200返50
    public ReturnCashStrategy(double condition, double returnCash){
        this.condition = condition;
        this.returnCash = returnCash;
    }
    @Override
    public double getResult() {
        double result = 0;
        result = this.getNumber() * this.getUnit();
        if(result >= condition){
            double k = result / condition;
            double returnCashTotal = k * returnCash;
            result = result - returnCashTotal;
        }
        return result;
    }
}
